<template>
  <ContentWrap>
    <!-- 搜索工作栏 -->
    <el-form
      class="-mb-15px"
      :model="queryParams"
      ref="queryFormRef"
      :inline="true"
      label-width="100px"
    >
      <el-form-item :label="t('ustcstudent.index.search.keyword')" prop="keyword">
        <el-input
          v-model="queryParams.keyword"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcstudent.index.search.keywordPlaceholder')
          "
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
          :disabled="advancedSearching"
        />
      </el-form-item>

      <el-form-item :label="t('ustcStudentInfoUniversity.fields.grade')" prop="grade">
        <el-select
          v-model="queryParams.grade"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.grade')
          "
          clearable
          class="!w-240px"
          @change="handleQuery"
          :disabled="advancedSearching"
        >
          <el-option
            v-for="(item, index) in gradeOptions"
            :key="index"
            :label="item"
            :value="item"
          />
        </el-select>
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.trainingLevel')"
        prop="trainingLevel"
      >
        <el-select
          v-model="queryParams.trainingLevel"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.trainingLevel')
          "
          clearable
          class="!w-240px"
          @change="handleQuery"
          :disabled="advancedSearching"
        >
          <el-option
            v-for="(item, index) in trainingLevelOptions"
            :key="index"
            :label="item"
            :value="item"
          />
        </el-select>
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.studentType')" prop="studentType">
        <el-select
          v-model="queryParams.studentType"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.studentType')
          "
          clearable
          class="!w-240px"
          @change="handleQuery"
          :disabled="advancedSearching"
        >
          <el-option
            v-for="(item, index) in studentTypeOptions"
            :key="index"
            :label="item"
            :value="item"
          />
        </el-select>
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.major')" prop="major">
        <el-select
          v-model="queryParams.major"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.major')
          "
          clearable
          class="!w-240px"
          @change="handleQuery"
          :disabled="advancedSearching"
        >
          <el-option
            v-for="(item, index) in majorOptions"
            :key="index"
            :label="item"
            :value="item"
          />
        </el-select>
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.classroom')" prop="classroom">
        <el-select
          v-model="queryParams.classroom"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.classroom')
          "
          clearable
          class="!w-240px"
          @change="handleQuery"
          :disabled="advancedSearching"
        >
          <el-option
            v-for="(item, index) in classroomOptions"
            :key="index"
            :label="item"
            :value="item"
          />
        </el-select>
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.trainingMethod')"
        prop="trainingMethod"
      >
        <el-select
          v-model="queryParams.trainingMethod"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.trainingMethod')
          "
          clearable
          class="!w-240px"
          @change="handleQuery"
          :disabled="advancedSearching"
        >
          <el-option
            v-for="(item, index) in trainingMethodOptions"
            :key="index"
            :label="item"
            :value="item"
          />
        </el-select>
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.studentStatus')"
        prop="studentStatus"
      >
        <el-select
          v-model="queryParams.studentStatus"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.studentStatus')
          "
          clearable
          class="!w-240px"
          @change="handleQuery"
          :disabled="advancedSearching"
        >
          <el-option
            v-for="(item, index) in studentStatusOptions"
            :key="index"
            :label="item"
            :value="item"
          />
        </el-select>
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.studentStatusChange')"
        prop="studentStatusChange"
      >
        <el-select
          v-model="queryParams.studentStatusChange"
          :placeholder="
            t('common.selectTextPlaceholder') +
            t('ustcStudentInfoUniversity.fields.studentStatusChange')
          "
          clearable
          class="!w-240px"
          @change="handleQuery"
          :disabled="advancedSearching"
        >
          <el-option
            v-for="(item, index) in studentStatusChangeOptions"
            :key="index"
            :label="item"
            :value="item"
          />
        </el-select>
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.primaryMentor')"
        prop="primaryMentor"
      >
        <el-input
          v-model="queryParams.primaryMentor"
          :placeholder="
            t('common.inputTextPlaceholder') + t('ustcStudentInfoUniversity.fields.primaryMentor')
          "
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
          :disabled="advancedSearching"
        />
      </el-form-item>
      <el-form-item :label="t('ustcStudentInfoUniversity.fields.inschoolFlag')" prop="inschoolFlag">
        <el-select
          v-model="queryParams.inschoolFlag"
          :placeholder="
            t('common.selectTextPlaceholder') + t('ustcStudentInfoUniversity.fields.inschoolFlag')
          "
          clearable
          class="!w-240px"
          @change="handleQuery"
          :disabled="advancedSearching"
        >
          <el-option
            v-for="(item, index) in inschoolFlagOptions"
            :key="index"
            :label="item"
            :value="item"
          />
        </el-select>
      </el-form-item>
      <el-form-item
        :label="t('ustcStudentInfoUniversity.fields.graduationConclusion')"
        prop="graduationConclusion"
      >
        <el-input
          v-model="queryParams.graduationConclusion"
          :placeholder="
            t('common.inputTextPlaceholder') +
            t('ustcStudentInfoUniversity.fields.graduationConclusion')
          "
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
          :disabled="advancedSearching"
        />
      </el-form-item>

      <el-form-item>
        <el-button @click="handleQuery" :disabled="advancedSearching">
          <Icon icon="ep:search" class="mr-5px" />
          {{ t('common.search') }}
        </el-button>
        <el-button @click="resetQuery" :disabled="advancedSearching">
          <Icon icon="ep:refresh" class="mr-5px" />
          {{ t('common.reset') }}
        </el-button>
        <el-button type="danger" @click="handleSync">
          <Icon icon="ep:switch" />
          {{ t('common.sync') }}
        </el-button>
        <!--        <el-button-->
        <!--          type="primary"-->
        <!--          plain-->
        <!--          @click="openForm('create')"-->
        <!--          v-hasPermi="['core:ustc-student:create']"-->
        <!--        >-->
        <!--          <Icon icon="ep:plus" class="mr-5px" />-->
        <!--          {{ t('action.add') }}-->
        <!--        </el-button>-->
        <el-button
          type="warning"
          plain
          @click="handleImport"
          v-hasPermi="['core:ustc-student:update']"
        >
          <Icon icon="ep:upload" class="mr-5px" />
          {{ t('action.importArp') }}
        </el-button>
        <el-button
          type="success"
          plain
          @click="handleExport"
          :loading="exportLoading"
          v-hasPermi="['core:ustc-student:export']"
        >
          <Icon icon="ep:download" class="mr-5px" />
          {{ t('action.export') }}
        </el-button>
        <ConditionTree
          id="student-condition-tree"
          :schemata="ustcStudentSchema"
          @search="handleAdvanceSearch"
        />
        <SendChat />
      </el-form-item>
    </el-form>
  </ContentWrap>

  <!-- 列表 -->
  <ContentWrap>
    <vxe-toolbar ref="toolbarRef" custom />
    <vxe-table
      id="iUstcStudent-table"
      ref="tableRef"
      v-loading="loading"
      :data="list"
      stripe
      :custom-config="vxeTableConfig"
      :column-config="{ resizable: true }"
      :size="vxeTableSize"
    >
      <vxe-column :title="t('common.index')" type="seq" field="seq" width="60" align="center" />
      <vxe-column
        :title="t('ustcstudent.fields.studentPhoto')"
        field="studentPhoto"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
      >
        <template #default="scope">
          <el-image
            class="student-avatar"
            :src="scope.row.studentPhoto"
            :preview-src-list="[scope.row.studentPhoto]"
            fit="cover"
          >
            <template #error>
              <div class="image-slot">
                {{ t('ustcstudent.view.noPhoto') }}
              </div>
            </template>
          </el-image>
        </template>
      </vxe-column>
      <vxe-column
        :title="t('ustcstudent.fields.admissionsPhoto')"
        field="admissionsPhoto"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
      >
        <template #default="scope">
          <el-image
            class="student-avatar"
            :src="scope.row.admissionsPhoto"
            :preview-src-list="[scope.row.admissionsPhoto]"
            fit="cover"
          >
            <template #error>
              <div class="image-slot">
                {{ t('ustcstudent.view.noPhoto') }}
              </div>
            </template>
          </el-image>
        </template>
      </vxe-column>
      <vxe-column
        :title="t('ustcstudent.fields.graduationPhoto')"
        field="graduationPhoto"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
      >
        <template #default="scope">
          <el-image
            class="student-avatar"
            :src="scope.row.graduationPhoto"
            :preview-src-list="[scope.row.graduationPhoto]"
            fit="cover"
          >
            <template #error>
              <div class="image-slot">
                {{ t('ustcstudent.view.noPhoto') }}
              </div>
            </template>
          </el-image>
        </template>
      </vxe-column>
      <vxe-column
        :title="t('ustcstudent.fields.studentCode')"
        field="studentCode"
        align="center"
        show-header-overflow
        show-overflow
        min-width="120"
      />
      <vxe-column
        :title="t('ustcstudent.fields.studentName')"
        field="studentName"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
      />
      <vxe-column
        :title="t('ustcstudent.fields.studentNamePinyin')"
        field="studentNamePinyin"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.studentNameUsed')"
        field="studentNameUsed"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.gender')"
        field="gender"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
      />
      <vxe-column
        :title="t('ustcstudent.fields.ethnic')"
        field="ethnic"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.birthdate')"
        field="birthdate"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :formatter="vxeDateFormatter2"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.nativePlace')"
        field="nativePlace"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.politicalStatus')"
        field="politicalStatus"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.identityType')"
        field="identityType"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.identityNumber')"
        field="identityNumber"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.passportNameEnglish')"
        field="passportNameEnglish"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.countryRegion')"
        field="countryRegion"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.marriageStatus')"
        field="marriageStatus"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.studentOrigin')"
        field="studentOrigin"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.birthPlace')"
        field="birthPlace"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.homeAddress')"
        field="homeAddress"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.residencePlace')"
        field="residencePlace"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.residenceAddress')"
        field="residenceAddress"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.residenceZipcode')"
        field="residenceZipcode"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.onePassCode')"
        field="onePassCode"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.stationUniversity')"
        field="stationUniversity"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.stationHome')"
        field="stationHome"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.personalPhone2')"
        field="personalPhone2"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.personalPhone3')"
        field="personalPhone3"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.personalEmail1')"
        field="personalEmail1"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.personalEmail2')"
        field="personalEmail2"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.personalEmailUniversity')"
        field="personalEmailUniversity"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.masterNumber')"
        field="masterNumber"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.phdNumber')"
        field="phdNumber"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.bachelorNumber')"
        field="bachelorNumber"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <!--      <vxe-column-->
      <!--        :title="t('ustcstudent.fields.trainingPeriod')"-->
      <!--        field="trainingPeriod"-->
      <!--        align="center"-->
      <!--        show-header-overflow-->
      <!--        show-overflow-->
      <!--        min-width="100"-->
      <!--        :visible="false"-->
      <!--      />-->
      <!--      <vxe-column-->
      <!--        :title="t('ustcstudent.fields.trainingInstitution')"-->
      <!--        field="trainingInstitution"-->
      <!--        align="center"-->
      <!--        show-header-overflow-->
      <!--        show-overflow-->
      <!--        min-width="100"-->
      <!--        :visible="false"-->
      <!--      />-->

      <!-- region 在校信息 -->
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.inschoolFlag')"
        field="inschoolFlag"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.studentStatus')"
        field="studentStatus"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.studentStatusChange')"
        field="studentStatusChange"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.admissionSeason')"
        field="admissionSeason"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.admissionTime')"
        field="admissionTime"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :formatter="vxeDateFormatter2"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.admissionType')"
        field="admissionType"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.studentType')"
        field="studentType"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.eduDuration')"
        field="eduDuration"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.trainingLevel')"
        field="trainingLevel"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.grade')"
        field="grade"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.faculty')"
        field="faculty"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.major')"
        field="major"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.category')"
        field="category"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.firstLevelSubject')"
        field="firstLevelSubject"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.professionalDirection')"
        field="professionalDirection"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.trainingMethod')"
        field="trainingMethod"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.learnMethod')"
        field="learnMethod"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.specialPlan')"
        field="specialPlan"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.elecAcademicRegNote')"
        field="elecAcademicRegNote"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.classroom')"
        field="classroom"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
      />
      <vxe-column
        :title="t('ustcstudent.fields.personalPhone1')"
        field="personalPhone1"
        align="center"
        show-header-overflow
        show-overflow
        min-width="120"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.primaryMentor')"
        field="primaryMentor"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.secondaryMentor')"
        field="secondaryMentor"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.residenceCampus')"
        field="residenceCampus"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.dormAddress')"
        field="dormAddress"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.basicPeriod')"
        field="basicPeriod"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :formatter="vxeDateFormatter2"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.longestPeriod')"
        field="longestPeriod"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :formatter="vxeDateFormatter2"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.registerStatus')"
        field="registerStatus"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.fundingPeriod')"
        field="fundingPeriod"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :formatter="vxeDateFormatter2"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.defenseDate')"
        field="defenseDate"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :formatter="vxeDateFormatter2"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.leaveDate')"
        field="leaveDate"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :formatter="vxeDateFormatter2"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.graduationConclusion')"
        field="graduationConclusion"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.graduationDate')"
        field="graduationDate"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :formatter="vxeDateFormatter2"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.graduationNumber')"
        field="graduationNumber"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.degreeType')"
        field="degreeType"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.degree')"
        field="degree"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.phdInResearch')"
        field="phdInResearch"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.transferYear')"
        field="transferYear"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.destinationType')"
        field="destinationType"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.destinationUnit')"
        field="destinationUnit"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.archiveAddress')"
        field="archiveAddress"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.archiveContact')"
        field="archiveContact"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoUniversity.fields.archiveTelephone')"
        field="archiveTelephone"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <!-- endregion -->

      <!-- region 入学信息 -->
      <vxe-column
        :title="t('ustcStudentInfoAdmission.fields.candidateNumber')"
        field="candidateNumber"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoAdmission.fields.admissionCategory')"
        field="admissionCategory"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoAdmission.fields.examMethod')"
        field="examMethod"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoAdmission.fields.trainingUnitLocation')"
        field="trainingUnitLocation"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoAdmission.fields.trainingUnit')"
        field="trainingUnit"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoAdmission.fields.rewardsSanctions')"
        field="rewardsSanctions"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoAdmission.fields.personalExperience')"
        field="personalExperience"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoAdmission.fields.familyInfo')"
        field="familyInfo"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <!-- endregion -->

      <!-- region 学位信息 -->
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.undergraduateSchool')"
        field="undergraduateSchool"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.undergraduateDate')"
        field="undergraduateDate"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :formatter="vxeDateFormatter2"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.undergraduateMajor')"
        field="undergraduateMajor"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.undergraduateStudyForm')"
        field="undergraduateStudyForm"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.bachelorUnit')"
        field="bachelorUnit"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.bachelorDate')"
        field="bachelorDate"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :formatter="vxeDateFormatter2"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.bachelorMajor')"
        field="bachelorMajor"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.bachelorCategory')"
        field="bachelorCategory"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.undergraduateNumber')"
        field="undergraduateNumber"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.undergraduateDegree')"
        field="undergraduateDegree"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.bachelorNumber')"
        field="bachelorNumber2"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.undergraduateQualification')"
        field="undergraduateQualification"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.masterGraduateUnit')"
        field="masterGraduateUnit"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.masterGraduateDate')"
        field="masterGraduateDate"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :formatter="vxeDateFormatter2"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.masterGraduateMajor')"
        field="masterGraduateMajor"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.masterMethod')"
        field="masterMethod"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.masterQualificationUnit')"
        field="masterQualificationUnit"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.masterQualificationDate')"
        field="masterQualificationDate"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :formatter="vxeDateFormatter2"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.masterQualificationMajor')"
        field="masterQualificationMajor"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.masterCategory')"
        field="masterCategory"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.masterGraduateNumber')"
        field="masterGraduateNumber"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.masterDegree')"
        field="masterDegree"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.masterQualificationNumber')"
        field="masterQualificationNumber"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoDegree.fields.masterQualification')"
        field="masterQualification"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <!-- endregion -->

      <!-- region 个人联系信息 -->
      <vxe-column
        :title="t('ustcStudentInfoPersonal.fields.wechat')"
        field="wechat"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoPersonal.fields.qq')"
        field="qq"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoPersonal.fields.homePhone')"
        field="homePhone"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoPersonal.fields.homeZipcode')"
        field="homeZipcode"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoPersonal.fields.homeAddress')"
        field="homeAddress2"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoPersonal.fields.emergencyContact')"
        field="emergencyContact"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoPersonal.fields.emergencyPhone')"
        field="emergencyPhone"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoPersonal.fields.emergencyAddress')"
        field="emergencyAddress"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoPersonal.fields.currentUnit')"
        field="currentUnit"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcStudentInfoPersonal.fields.currentAddress')"
        field="currentAddress"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <!-- region -->

      <vxe-column
        :title="t('ustcstudent.fields.remark')"
        field="remark"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
      />
      <vxe-column
        :title="t('ustcstudent.fields.researchDept')"
        field="researchDept"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
      />
      <vxe-column
        :title="t('ustcstudent.fields.arpNumber')"
        field="arpNumber"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
      />
      <vxe-column
        :title="t('ustcstudent.fields.createTime')"
        field="createTime"
        align="center"
        show-header-overflow
        show-overflow
        min-width="100"
        :visible="false"
        :formatter="vxeDateFormatter"
      />
      <vxe-column
        :title="t('common.operate')"
        field="operator"
        align="center"
        fixed="right"
        width="80"
      >
        <template #default="scope">
          <el-button link type="primary" @click="showStudentInfo(scope.row.accountId)">
            {{ t('action.detail') }}
          </el-button>
          <!--          <el-button-->
          <!--            link-->
          <!--            type="danger"-->
          <!--            @click="handleDelete(scope.row.id)"-->
          <!--            v-hasPermi="['core:ustc-student:delete']"-->
          <!--          >-->
          <!--            {{ t('action.delete') }}-->
          <!--          </el-button>-->
        </template>
      </vxe-column>
    </vxe-table>
    <!-- 分页 -->
    <Pagination
      :total="total"
      v-model:page="queryParams.pageNo"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </ContentWrap>

  <!-- 表单弹窗：添加/修改 -->
  <UstcStudentForm ref="formRef" @success="getList" />
  <UstcStudentView ref="studentViewRef" @refresh="getList" />
  <ExcelImportForm
    ref="importFormRef"
    object-name="ARP号"
    upload-url="/core/ustc-student/import"
    template-url="/core/ustc-student/get-import-template"
    @success="getList"
  />
</template>

<script setup lang="ts">
import { vxeDateFormatter, vxeDateFormatter2 } from '@/utils/formatTime'
import download from '@/utils/download'
import { UstcStudentApi, UstcStudentVO } from '@/api/core/ustcstudent'
import UstcStudentForm from './UstcStudentForm.vue'
import UstcStudentView from './components/UstcStudentView.vue'
import ExcelImportForm from '@/components/ExcelImportForm/index.vue'
import type { VxeTableInstance, VxeTablePropTypes, VxeToolbarInstance } from 'vxe-table'
import { ustcStudentSchema } from '@/views/core/ustcstudent/schema'
import { useAppStore } from '@/store/modules/app'
import SendChat from '@/components/SendChat/index.vue'
import {
  UstcStudentInfoUniversityApi,
  UstcStudentInfoUniversitySelectRespVO
} from '@/api/core/ustcstudentinfouniversity'

// 科大学生信息 列表
defineOptions({ name: 'UstcStudent' })

const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化

const toolbarRef = ref<VxeToolbarInstance>()
const tableRef = ref<VxeTableInstance>()

const loading = ref(true) // 列表的加载中
const list = ref<UstcStudentVO[]>([]) // 列表的数据
const total = ref(0) // 列表的总页数
const advancedSearching = ref(false) // 高级搜索
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  advanced: undefined,

  keyword: undefined,
  grade: undefined,
  trainingLevel: undefined,
  studentType: undefined,
  major: undefined,
  classroom: undefined,
  trainingMethod: undefined,
  studentStatus: undefined,
  studentStatusChange: undefined,
  primaryMentor: undefined,
  inschoolFlag: undefined,
  graduationConclusion: undefined,

  accountId: undefined,
  infoRuleId: undefined,
  studentPhoto: undefined,
  admissionsPhoto: undefined,
  graduationPhoto: undefined,
  studentCode: undefined,
  studentName: undefined,
  studentNamePinyin: undefined,
  studentNameUsed: undefined,
  gender: undefined,
  ethnic: undefined,
  birthdate: [],
  nativePlace: undefined,
  politicalStatus: undefined,
  identityType: undefined,
  identityNumber: undefined,
  passportNameEnglish: undefined,
  countryRegion: undefined,
  marriageStatus: undefined,
  studentOrigin: undefined,
  birthPlace: undefined,
  homeAddress: undefined,
  residencePlace: undefined,
  residenceAddress: undefined,
  residenceZipcode: undefined,
  onePassCode: undefined,
  stationUniversity: undefined,
  stationHome: undefined,
  personalPhone1: undefined,
  personalPhone2: undefined,
  personalPhone3: undefined,
  personalEmail1: undefined,
  personalEmail2: undefined,
  personalEmailUniversity: undefined,
  masterNumber: undefined,
  phdNumber: undefined,
  bachelorNumber: undefined,
  trainingPeriod: undefined,
  trainingInstitution: undefined,
  remark: undefined,
  mentorId: undefined,
  mentorCode: undefined,
  mentorName: undefined,
  researchDeptId: undefined,
  researchDept: undefined,
  createTime: []
})
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中

const studentViewRef = ref<InstanceType<typeof UstcStudentView>>()

const vxeTableConfig: VxeTablePropTypes.CustomConfig = {
  storage: true,
  mode: 'drawer',
  checkMethod({ column }) {
    return !['seq', 'operator'].includes(column.field)
  }
}

const appStore = useAppStore()
const vxeTableSize = computed(() => appStore.getCurrentSizeVxe)

/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    const data = await UstcStudentApi.getUstcStudentPage(queryParams)
    list.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}

/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.pageNo = 1
  getList()
}

/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value.resetFields()
  advancedSearching.value = false
  ;(queryParams as any).advanced = undefined
  handleQuery()
}

/** 添加/修改操作 */
const formRef = ref<InstanceType<typeof UstcStudentForm>>()
const openForm = (type: string, id?: number) => {
  formRef.value?.open(type, id)
}

/** 导入 */
const importFormRef = ref<InstanceType<typeof ExcelImportForm>>()
const handleImport = () => {
  importFormRef.value?.open()
}

/** 删除按钮操作 */
const handleDelete = async (id: number) => {
  try {
    // 删除的二次确认
    await message.delConfirm()
    // 发起删除
    await UstcStudentApi.deleteUstcStudent(id)
    message.success(t('common.delSuccess'))
    // 刷新列表
    await getList()
  } catch {}
}

/** 导出按钮操作 */
const handleExport = async () => {
  try {
    // 导出的二次确认
    await message.exportConfirm()
    // 发起导出
    exportLoading.value = true
    const data = await UstcStudentApi.exportUstcStudent(queryParams)
    download.excel(data, '中国科大学生信息.xlsx')
  } catch {
  } finally {
    exportLoading.value = false
  }
}

const handleAdvanceSearch = (base64Advanced?: string) => {
  ;(queryParams as any).advanced = base64Advanced
  advancedSearching.value = !!base64Advanced
  handleQuery()
}

const showStudentInfo = (id: number) => {
  studentViewRef.value?.open(id)
}

const handleSync = async () => {
  try {
    await message.confirm(t('ustcstudent.sync.syncTip'))
    const response = await UstcStudentApi.syncNow()
    if (response) {
      message.success(t('ustcstudent.sync.syncSuccess'))
    } else {
      message.error(t('ustcstudent.sync.syncFail'))
    }
  } catch {}
}

const gradeOptions = ref<string[]>([])
const trainingLevelOptions = ref<string[]>([])
const studentTypeOptions = ref<string[]>([])
const majorOptions = ref<string[]>([])
const classroomOptions = ref<string[]>([])
const trainingMethodOptions = ref<string[]>([])
const studentStatusOptions = ref<string[]>([])
const studentStatusChangeOptions = ref<string[]>([])
const inschoolFlagOptions = ref<string[]>([])
const getSelect = async () => {
  const response: UstcStudentInfoUniversitySelectRespVO =
    await UstcStudentInfoUniversityApi.getStudentInfoUniversitySelect()
  if (response) {
    gradeOptions.value = response.grade
    trainingLevelOptions.value = response.trainingLevel
    studentTypeOptions.value = response.studentType
    majorOptions.value = response.major
    classroomOptions.value = response.classroom
    trainingMethodOptions.value = response.trainingMethod
    studentStatusOptions.value = response.studentStatus
    studentStatusChangeOptions.value = response.studentStatusChange
    inschoolFlagOptions.value = response.inschoolFlag
  }
}

/** 初始化 **/
onMounted(() => {
  getList()

  const table = tableRef.value
  const toolbar = toolbarRef.value
  if (table && toolbar) {
    table.connect(toolbar)
  }

  getSelect()
})
</script>

<style lang="scss" scoped>
.student-avatar {
  width: 80px;
  height: 80px;
  display: block;
  margin: 5px auto;
  border-radius: 6px;

  :deep(.image-slot) {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    background: var(--el-fill-color-light);
    color: var(--el-text-color-secondary);
    font-size: 14px;
  }
}
</style>
